URLを外部リンク記法に変換するPopup Menu (TamperMonkeyなし)
code:mod.ts
import { convert, hasURL } from "../URLを外部リンク記法に変換するUserScript_(TamperMonkeyなし)/mod.ts";
import { insertText } from "../scrapbox-userscript-std/dom.ts";
import type { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts";
declare const scrapbox: Scrapbox;
scrapbox.PopupMenu.addButton({
title: (text) => hasURL(text) ? "URL" : "",
onClick: (text): undefined => {
if (!hasURL(text)) return;
(async () => {
const newText = await convert(text);
if (newText === text) return;
await insertText(newText);
})();
},
});